package strategy_pattern.v5;

/**
 * 策略模式context
 */
public class CashContext {
    private CashSuper cashSuper;

    public CashContext(String benefitType) {
        switch (benefitType) {
            case "0":
                this.cashSuper = new CashNormal();
                break;
            case "1":
                this.cashSuper = new CashRebate(0.8);
                break;
            case "2":
                this.cashSuper = new CashRebate(0.7);
                break;
            case "3":
                this.cashSuper = new CashRebate(0.5);
                break;
            case "4":
                this.cashSuper = new CashReturn(300, 100);
                break;
        }
    }

    public double getResult(double money) {
        return cashSuper.acceptCash(money);
    }
}
